import React from 'react';
import {
  BarcodeOutlined,
  createFromIconfontCN,
  InfoCircleOutlined,
  CommentOutlined,
} from '@ant-design/icons';
import style from './Components.module.scss';
import {Popover, Space} from 'antd';
import {Typography} from 'antd/es';

const IconFont = createFromIconfontCN({
  scriptUrl: '//at.alicdn.com/t/font_2957530_vmvi1jrzeyg.js',
});

export const SourceLogo=({source, noMargin=false})=>{
  if (source==='jd') {
    return <IconFont style={{marginLeft: noMargin?0:8}}
      className={style.jdIcon} type={'icon-jingdong'}/>;
  }
  if (source==='dd') {
    return <IconFont style={{marginLeft: noMargin?0:8}}
      className={style.ddIcon} type={'icon-dangdangwang'}/>;
  }
  if (source==='isbn') {
    return <Space className={style.isbn}>
      <span>
        <BarcodeOutlined style={{marginLeft: noMargin?0:12}}/>
        <span className={style.text}>ISBN</span>
      </span>
      <Popover content={'为数据库中缺失部分字段的 ISBN 条目爬取信息'}>
        <Typography.Text type={'secondary'}>
          <InfoCircleOutlined />
        </Typography.Text>
      </Popover>
    </Space>;
  }
  if (source==='comment') {
    return <CommentOutlined style={{marginLeft: noMargin?0:8}}/>;
  }
};
